<%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta name="description" content="" />
		<meta name="keywords" content="" />
		<title>${title}</title>
		<link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css" />
		<link href="http://fonts.googleapis.com/css?family=Kreon" rel="stylesheet" type="text/css" />
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/resources/style.css" />
	</head>
	<body>
		<div id="wrapper">
			<div id="header">
				<div id="logo">
					<h1><a href="${pageContext.request.contextPath}">Code<br />Storage</a></h1>
				</div>
				<div id="menu">
					<ul>
						<li class="first <c:if test="${page == 0}">active</c:if>"><a href="${pageContext.request.contextPath}">Home</a></li>
						<security:authorize access="isAuthenticated()">
							<li <c:if test="${page == 3}">class="active"</c:if>><a href="/CodeStorage/profile">Profil</a></li>
							<li <c:if test="${page == 4}">class="active"</c:if>><a href="/CodeStorage/application/upload">Přidat aplikaci</a></li>
						</security:authorize>
						<li <c:if test="${page == 1}">class="active"</c:if>><a href="${pageContext.request.contextPath}/search">Hledání</a></li>
						<c:if test="${page == 2}">
							<li class="first active"><a href="#">Detail aplikace</a></li>
						</c:if>
					</ul>
					<br class="clearfix" />
				</div>
			</div>
			<div id="page">
				<div id="sidebar">
					<security:authorize access="isAuthenticated()"> 
						<div class="box">
						   <table>
						    <tr>
						     	<td>Uživatel:</td>
						     	<td style="padding-left: 3px"><strong>${pageContext.request.userPrincipal.name}</strong></td>
						     	<td style="padding-left: 3px"><a href="/CodeStorage/j_spring_security_logout" > Odhlásit</a></td>
						     </tr>
						   </table>
						</div>
            		</security:authorize>
            		<security:authorize access="!isAuthenticated()"> 
						<div class="box">
						<c:if test="${loginFailed}">
   							<div style="color: red">Příhlášení se nezdařilo!</div>
  						</c:if>
						<form method="post" class="signin" action="/CodeStorage/j_spring_security_check">
						   <table>
						    <tr>
						     <th><label for="login">Login</label></th>
						     <td><input id="username_or_email" name="j_username" type="text" /></td>
						    </tr>
						    <tr>
						     <th><label for="password">Password</label></th>
						     <td><input id="password" name="j_password" type="password" /></td>
						    </tr>
						    <tr>
						     <td><input name="commit" type="submit" class="gobuttonII" value="Přihlásit" /></td>
						     <td><a href="/CodeStorage/register" > Registrovat</a></td>
						    </tr>
						   </table>
						  </form>
						</div>
            		</security:authorize>
					<div class="box">
						<h3>Nejnovější</h3>
						<c:import url="/newapps"></c:import>
					</div>
					<div class="box">
						<h3>Nejstahovanější</h3>
						<c:import url="/topdownapps"></c:import>
					</div>
					<div class="box">
						<h3>Nejlépe hodnocené</h3>
						<c:import url="/topapps"></c:import>
					</div>
				</div>
				<div id="content">  
					<jsp:include page="/WEB-INF/views/${view}.jsp"></jsp:include>
					<br class="clearfix" />
				</div>
				<br class="clearfix" />
			</div>
			<div id="page-bottom">
				<div id="page-bottom-sidebar">
					<h3>Autoři</h3>
					<ul class="list">
						<li class="first"><a href="mailto:xvalen12@stud.fit.vutbr.cz">xvalen12</a></li>
						<li><a href="mailto:xfalha00@stud.fit.vutbr.cz">xfalha00</a></li>
					</ul>
				</div>
				<div id="page-bottom-content">
					<h3>O projektu</h3>
					<p>
						Projekt vznikl jako původní dílo v rámci předmětu GJA 2013 na FIT VUT v Brně. Všechna práva vyhrazena. 
					</p>
				</div>
				<br class="clearfix" />
			</div>
		</div>
		<div id="footer">
			&copy; 2013 Code storage | Design by <a href="http://www.freecsstemplates.org/">FCT</a>
		</div>
	</body>
</html>
